package com.example.controller;

import com.example.data.request.ReqMasterList;
import com.example.entity.Master;
import com.example.service.impl.MasterServiceImpl;
import com.example.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Author:yanghua
 * Date:2023/10/7 8:27
 */
@Slf4j
@RestController
@RequestMapping("master")
public class MasterController {
    @Resource
    private MasterServiceImpl masterService;
    @PostMapping("addMaster")
    private R add(@RequestBody Master master) {
        return masterService.addMaster(master);
    }
    @DeleteMapping("deleteById/{id}")
    private R delete(@PathVariable Long id) {
        return masterService.deleteById(id);
    }
    @PostMapping("getMasterList")
    private R getMasterList(@RequestBody ReqMasterList reqMasterList) {
        return masterService.getMasterList(reqMasterList);
    }
    @GetMapping("getMasterByUsername/{username}")
    private R getMasterByUsername(@PathVariable String username) {
        return masterService.getMasterByUsername(username);
    }
    @GetMapping("getMasterById/{id}")
    private R getMasterById(@PathVariable Long id) {
        return masterService.getMasterById(id);
    }
    @PutMapping("updateMaster")
    private R updateMaster(@RequestBody Master master) {
        return masterService.updateMaster(master);
    }
}
